<template>
    <el-dialog
      :title="title"
      destroy-on-close
      append-to-body
      :visible.sync="show"
      width="1000px"
      :before-close="cancel">
      <el-table show-summary :summary-method="handleSum" ref="TableRef" :data="tabelDeta">
        <el-table-column show-overflow-tooltip :label="$t('包裹号')" align="center" prop="packageNo" />
        <el-table-column show-overflow-tooltip :label="$t('最终快递方式')" align="center" prop="deliveryWayFinal" />
        <el-table-column show-overflow-tooltip :label="$t('包裹份数')" align="center" prop="packageNum" />
        <el-table-column show-overflow-tooltip :label="$t('运费')" align="center" prop="deliveryFee">
        </el-table-column>
        <el-table-column show-overflow-tooltip :label="$t('捆包费')" align="center" prop="bundleFee" />
      </el-table>
    </el-dialog>
  </template>
  <script>
  import handleTableSum from '@/utils/handleSum'
  
  import {billSellerFeeInfo } from '@/api/bill/seller'
  export default {
    activated() {
      this.$nextTick(() => this.$refs['TableRef']?.doLayout())
    },
    props: {
      data: {
        type: Object,
        default: () => {},
      },
      title:{
          type:String,
      },
         /**
       * 控制显示隐藏
       */
       show: {
        type: Boolean,
        default: false,
      },
    },
    data() {
      return {
        tabelDeta: [],
      }
    },
    methods: {
      handleSum(param) {
        /**
         * 需要进行统计的字段
         */
        const data = handleTableSum(param, ['deliveryFee','bundleFee'] ,'合计',0)
        console.log(`data ==>`, JSON.parse(JSON.stringify(data)))
        return data
      },
  
      cancel() {
          console.log('执行了');
        this.$emit('update:show', false)
      },
    },
    watch:{
      show:function (params) {
          if (params) {
              billSellerFeeInfo({id:this.data.id,type:2}).then((res)=>{
                  this.tabelDeta =res.data.expressFeeBundleFeeList
              })
          }
      }
    }
  }
  </script>
  